package com.apes.hr.salary.rewardPunish.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.hr.salary.rewardPunish.model.TeamRewardPunish;
import com.apes.scm.masterdata.frame.model.Branch;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author linwz
 * @create 2019-02-27 09:47
 */
public interface TeamRewardPunishRepository extends CustomRepository<TeamRewardPunish, String>{

//    @Query(value = "SELECT * from hr_Team_Reward_Punish t,hr_team_Reward_Punish_item a WHERE t.id = a.team_reward_punish_id  AND a.work_branch_id = ?1 AND a.distribution =0 and t.state = 'sendOut'",nativeQuery = true)
//    List<TeamRewardPunish> findByBranchAndDistribution(Branch branch);


    @Query("SELECT t FROM TeamRewardPunish t , TeamRewardPunishItem a WHERE t.state = :state and t.id = a.teamRewardPunish and a.distribution = 0 and a.workBranch =:branch ")
    Page<TeamRewardPunish> findByBranch(@Param("branch") Branch branch,@Param("state") String state, Pageable pageable);
}
